package com.example.sxy_project;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import java.util.ArrayList;
import java.util.List;

public class TongxunluFragment extends Fragment {
    private List<Tongxunlu> tongxunluList = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.tongxunlu_fragment,container,false);
    }

    @Override

    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        inints();

        TongxunluAdapter adapter = new TongxunluAdapter(this.getContext(),R.layout.txl_content_item,
                tongxunluList);
        ListView listView = getView().findViewById(R.id.txl_listview);
        listView.setAdapter(adapter);
    }

    private void inints() {
        Tongxunlu t1 = new Tongxunlu();
        t1.setImageId(R.drawable.xdpy);
        t1.setName("新的朋友");
        tongxunluList.add(t1);

        Tongxunlu t2 = new Tongxunlu();
        t2.setImageId(R.drawable.ql);
        t2.setName("群聊");
        tongxunluList.add(t2);

        Tongxunlu t3 = new Tongxunlu();
        t3.setImageId(R.drawable.bq);
        t3.setName("标签");
        tongxunluList.add(t3);

        Tongxunlu t4 = new Tongxunlu();
        t4.setImageId(R.drawable.dyhxx);
        t4.setName("公众号");
        tongxunluList.add(t4);

        for (int i=0;i<2;i++){
            Tongxunlu t5 = new Tongxunlu();
            t5.setImageId(R.drawable.img2);
            t5.setName("宋欣益");
            tongxunluList.add(t5);

            Tongxunlu t6 = new Tongxunlu();
            t6.setImageId(R.drawable.img1);
            t6.setName("宋宋");
            tongxunluList.add(t6);

            Tongxunlu t7 = new Tongxunlu();
            t7.setImageId(R.drawable.img3);
            t7.setName("不想上学");
            tongxunluList.add(t7);

            Tongxunlu t8 = new Tongxunlu();
            t8.setImageId(R.drawable.img4);
            t8.setName("小宋");
            tongxunluList.add(t8);

            Tongxunlu t9 = new Tongxunlu();
            t9.setImageId(R.drawable.img5);
            t9.setName("噔噔");
            tongxunluList.add(t9);

            Tongxunlu t10 = new Tongxunlu();
            t10.setImageId(R.drawable.img3);
            t10.setName("小允");
            tongxunluList.add(t10);
        }


    }

}
